﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FT
{
    // Code Start
    // The base class of all TextFile
    public class TextFile
    {
        public string FileName { get; set; }

        public virtual string Read()
        {
            string filePath = GetPath(FileName);
            // Read from text file to string using filePath value
            return string.Empty;
        }

        public virtual bool Write(string data)
        {
            string filePath = GetPath(FileName);
            // Write string to file using filePath value
            return true;
        }

        protected string GetPath(string fileName)
        {
            // Search file and return the full file path
            return string.Empty;
        }
    }


    // The text data file
    public class DataTextFile : TextFile
    {
        public double DataSize
        {
            get
            {
                string filePath = GetPath(FileName);
                // calculate the size of text data file
                return 0;
            }
        }
    }


    public class MainProgram
    {
        public static void Main()
        {
            // Main program
            // put your code here…….

            try
            {
                OrderProcess();
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            finally
            {
                OnSuccessed();
                CleanUp();
            }

            //TextFile file1 = new TextFile();
            //file1.FileName = " somefile.dat";
            //string fileContent = file1.Read();

            //DataTextFile file1 = new DataTextFile();
            //file1.FileName = "somefile.dat";
            //string fileContent = file1.Read();

            //TextFile file1 = new DataTextFile();
            //file1.FileName = " somefile.dat";
            //double dataSize = file1.DataSize;

            //DataTextFile file1 = new DataTextFile();
            //file1.FileName = " somefile.dat";
            //double dataSize = file1.DataSize;

            //TextFile file1 = new DataTextFile();
            //file1.FileName = " somefile.dat";
            //string fileContent = file1.Read();

            Console.ReadKey();
        }

        private static void CleanUp()
        {
            Console.WriteLine("Clean Up");
        }

        private static void OnSuccessed()
        {
            Console.WriteLine("On successed is called");
        }

        private static void LogError(Exception ex)
        {
            Console.WriteLine("Log error : " + ex.Message);
        }

        private static void OrderProcess()
        {
            Console.WriteLine("Order Process");
        }
    }
    // Code End


}
